// 引入 ECharts 主模块
var echarts = require('echarts/lib/echarts')
import 'echarts-gl'
// 引入柱状图
require('echarts/lib/chart/bar')
require('echarts/lib/chart/line')
// 引入提示框和标题组件
require('echarts/lib/component/tooltip')
require('echarts/lib/component/title')
require('echarts/lib/component/legend')
require('echarts/lib/component/grid')
require('echarts/map/js/china.js')
import rockBg from '@/assets/dashboard/rock.png'
export default class EchartsConfig {
  private myChart: any
  private option = {
    tooltip: {
      show: false
    },
    series: [
      {
        type: 'map3D',
        map: 'china',
        roam: true,
        shading: 'realistic',
        realisticMaterial: {
          roughness: 0.6,
          textureTiling: 5,
          detailTexture: rockBg
        },
        viewControl: {
          distance: 85,
          alpha: 40
        },
        itemStyle: {
          areaColor: '#fff',
          opacity: 1,
          borderWidth: 1.5,
          borderColor: 'rgba(2, 132, 227, 0.8)'
        },
        label: {
          show: false
        },
        emphasis: {
          //当鼠标放上去  地区区域是否显示名称
          label: {
            show: true,
            textStyle: {
              color: '#fff',
              fontSize: 20,
              backgroundColor: 'transparent'
            }
          },
          itemStyle: {
            color: 'rgb(0, 138, 243)'
          }
        },
        //shading: 'lambert',
        light: {
          //光照阴影
          main: {
            color: '#fff', //光照颜色
            intensity: 1.2, //光照强度
            //shadowQuality: 'high', //阴影亮度
            shadow: false, //是否显示阴影
            alpha: 55,
            beta: 10
          },
          ambient: {
            intensity: 0.3
          }
        },
        data: []
      }
    ]
  }
  constructor(domId: string) {
    this.myChart = echarts.init(document.getElementById(domId))
  }
  public setOption(data: any) {
    this.option.series[0].data = []
    ;(this.option.series[0].data as Array<[]>).push(data)
    this.myChart && this.myChart.setOption(this.option)
  }
}
